const AUTH = require('../../utils/auth')
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    // userName: wx.getStorageSync('userName'),
    // navHeight:""
    userInfo:null,
    hasUserInfo: false,
    show_sign: false,  //签名显示
    canIUseGetUserProfile: false,
    uesrName:wx.getStorageSync('prolist')==''?wx.getStorageSync('prolist'):JSON.parse(wx.getStorageSync('prolist'))
  },

  logout() {
    AUTH.logout()
  },
  openSing(){
		this.setData({
			show_sign: true
		})
	},
	saveSign(src){
		console.log(src)
		this.setData({
			show_sign: false
		})
	},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
        let userinfo = wx.getStorageSync('userInfo')==''?wx.getStorageSync('userInfo'):JSON.parse(wx.getStorageSync('userInfo'))
        console.log(userinfo);
        if(userinfo!=''){
          this.setData({
            userInfo:userinfo,
            hasUserInfo: true
          })
        }
      
   this.phoneNavHeight()
   if (wx.getUserProfile) {
    this.setData({
      canIUseGetUserProfile: true,
    })
  }
  },

  


  
  //取得导航栏高度
  phoneNavHeight: function () {
    let that = this;
    wx.getSystemInfo({
      success: function(res) {
        let height = res.statusBarHeight + (res.platform === "ios" ? 44 : 48);
        let rule = 750/res.windowWidth;
        height = height * rule;

        that.setData({
          navHeight: height
        })
      }
    })
  },

  getUserProfile() {
    wx.getUserProfile({
      desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
      success: (res) => {
        console.log(res);
        wx.setStorageSync('userInfo', JSON.stringify(res.userInfo))
        this.setData({
          userInfo:res.userInfo,
          hasUserInfo: true
        })
      }
    })
  }

 
})